﻿<UserControl 
    x:Class="Sidvall.UI.Uwp.Controls.ProgressControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Sidvall.UI.Uwp.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:vms="using:Sidvall.UI.ViewModels"
    xmlns:converters="using:Sidvall.UI.Uwp.Converters" 
    xmlns:controls2="using:Sidvall.UI.Uwp.Controls"
    mc:Ignorable="d"
    d:DesignHeight="300"
    d:DesignWidth="400">

    <UserControl.Resources>
        <converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
    </UserControl.Resources>

    <Grid d:DataContext="{d:DesignInstance vms:ProgressControlViewModel, IsDesignTimeCreatable=True}">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

            <TextBox Text="{Binding MonitoredTaskItem.Description}" IsReadOnly="True" AcceptsReturn="True" TextWrapping="Wrap" 
                     ScrollViewer.VerticalScrollBarVisibility="Auto" />
            <StackPanel Grid.Row="1">
                <StackPanel Visibility="{Binding MonitoredTaskItem.ShowProgress, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay}">
                    <ProgressBar Height="23" Value="{Binding MonitoredTaskItem.Progress}" Margin="0,5,0,0" />
                </StackPanel>
                <StackPanel Visibility="{Binding MonitoredTaskItem.ShowTime, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay}">
                    <Grid Margin="0,5,0,0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="70" />
                            <ColumnDefinition Width="80" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>

                        <TextBlock Text="Time:" Padding="0,5,0,5" />
                        <TextBox Grid.Column="1" Text="{Binding MonitoredTaskItem.CompletedTimeText, Mode=OneWay}" IsReadOnly="True" VerticalContentAlignment="Center" HorizontalContentAlignment="Right" />
                    </Grid>
                </StackPanel>
                <StackPanel Visibility="{Binding MonitoredTaskItem.ShowTimeLeft, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay}">
                    <Grid Margin="0,5,0,0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="70" />
                            <ColumnDefinition Width="80" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>

                        <TextBlock Text="Time left:" Padding="0,5,0,5" />
                        <TextBox Grid.Column="1" Text="{Binding MonitoredTaskItem.TimeLeftText, Mode=OneWay}" IsReadOnly="True" VerticalContentAlignment="Center" HorizontalContentAlignment="Right" />
                    </Grid>
                </StackPanel>
                <StackPanel Visibility="{Binding MonitoredTaskItem.ShowSpeed, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay}">
                    <Grid Margin="0,5,0,0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="70" />
                            <ColumnDefinition Width="80" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>

                        <TextBlock Grid.Column="0" Text="Speed:" Padding="0,5,0,5" />
                        <TextBox Grid.Column="1" Text="{Binding MonitoredTaskItem.SpeedText, Mode=OneWay}" IsReadOnly="True" HorizontalContentAlignment="Right" />
                        <TextBlock Grid.Column="2" Text="{Binding MonitoredTaskItem.SpeedUnit}" />
                    </Grid>
                </StackPanel>
                <StackPanel Visibility="{Binding MonitoredTaskItem.CanCancel, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay}">
                    <CheckBox Margin="0,5,0,0" IsChecked="{Binding CloseWhenFinished, Mode=TwoWay}" HorizontalAlignment="Left" 
                              VerticalContentAlignment="Top" Content="Close dialog when finished" />
                </StackPanel>
            </StackPanel>
        </Grid>
    </Grid>
</UserControl>
